/*
 * Node.cpp
 *
 *  Created on: 18/09/2011
 *      Author: godinho
 */

#include <localview/Node.h>

Node::Node(std::string id) : mId(id) {
	mTraversalStatus = 0;
}

Node::~Node() {
	/**
	 * TODO I need to dealoc mNeighbors ? I think that std::vector do this
	 * already.
	 */
}

void Node::addStreet(Street* street) {

	/*
	 * TODO check for repeated streets
	 */
	mStreets.push_back(street);
}

void Node::addNeighbor(Node* node, int direction) {
	mNeighbors.push_back(node);
}

Street* Node::getStreetByName(std::string streetName) {
	std::vector<Street*>::iterator it;

	for(it = mStreets.begin(); it != mStreets.end(); it++) {
		if((*it)->getStreetName() == streetName) {
			return (*it);
		}
	}

	return 0;
}

std::string Node::getNodeId() {
	return mId;
}

std::string Node::getAddress() {
	return mAddress;
}

void Node::setAddress(std::string address) {
	mAddress = address;
}

void Node::addPhase(Phase* phase) {
	mPhases.push_back(phase);
}

int Node::getPhaseCount() {
	return mPhases.size();
}

Phase* Node::getPhase(int n) {
	return mPhases[n];
}

int Node::getX(){
	return mX;
}

void Node::setX(int x){
	mX = x;
}

int Node::getY(){
	return mY;
}

void Node::setY(int y) {
	mY = y;
}

void Node::setTraversalStatus(int s) {
	mTraversalStatus = s;
}

int Node::getTraversalStatus() {
	return mTraversalStatus;
}

std::vector<Node*> Node::getNeighbors() {
	return mNeighbors;
}

std::vector<Phase*> Node::getPhases() {
	return mPhases;
}
